<template>
    <el-row>
        <el-col :span="24">
         <el-input v-bind="$attrs" v-model="fieldValue[0]" placeholder="标题名称"></el-input>

        </el-col>
        <el-col :span="24">
           <el-input v-model="fieldValue[1]" v-bind="$attrs" placeholder="别名"></el-input>

        </el-col>
    </el-row>
</template>

<script>
  import vPinyin from '@/utils/vue-py'
  export default {
    props: {
      value: {
        type: Array,
        default() {
          return []
        }
      },
    },
    data(){
        return {
            title:'',
            alias:'',
        }
    },
    computed: {
      fieldValue: {
        get() {
          if(this._.isArray(this.value) && this.value.length) {
            this.title = this.value[0];
            this.alias = this.value[1];
          }
          return this.value || []
        },
        set(val) {
          this.$emit('input', val)
        }
      }
    },
    watch: {
      title(val) {
          this.getAlias(val);
      },
    },
    methods: {
        getAlias(val){
            this.alias = vPinyin.chineseToPinYin(val);
            this.fieldValue = [this.title,this.alias];
            return false;
        }
    }
  }
</script>
